import Vue from 'vue'
const store = {
  // 获取列表
  storeList: function storeList(ip, postdata) {
    var ipStr = ip + "/" + postdata.pageSize + "/" + postdata.number
    return Vue.http.post(ipStr, postdata).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  },
  // 添加套餐
  storeAdd: function storeAdd(ip, postdata) {
    console.log(postdata, ip)
    return Vue.http.post(ip, postdata).then(response => {
      console.log('end')
      if (response.status === 200) {
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  },
  // 删除套餐
  storeDel: function storeDel(ip, postdata) {
    console.log(postdata, ip)
    var ipStr = ip + "/" + postdata.id
    return Vue.http.post(ipStr, postdata).then(response => {
      console.log('end')
      if (response.status === 200) {
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  },
  // 商户搜索
  storeSeek: function storeSeek(ip, postdata) {
    console.log(postdata, ip)
    return Vue.http.post(ip, postdata).then(response => {
      console.log('end')
      if (response.status === 200) {
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  },
  // 商户详情
  storeDetails: function storeDetails(ip, postdata) {
    console.log(postdata, ip)
    var ipStr = ip + "/" + postdata.id
    return Vue.http.get(ipStr, {}).then(response => {
      console.log('end')
      if (response.status === 200) {
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  }
}

export default store
